d/tests/build: Update for GTK+ 4.0
authorSimon McVittie <smcv@debian.org>
Fri, 14 Sep 2018 14:30:59 +0000 (15:30 +0100)
committerSimon McVittie <smcv@debian.org>
Fri, 14 Sep 2018 15:48:48 +0000 (16:48 +0100)
debian/changelog
debian/tests/build [changed mode: 0644->0755]

index 2d818c375ae8ef58671b260cb93869c5e870a5c8..bdda2a0c7b6b9ce3aebc3bf2dfae9b773769c6ae 100644 (file)
@@ -55,6 +55,7 @@ gtk+4.0 (3.94.0-1) UNRELEASED; urgency=medium
   * libgtk-4-0.postrm.in: Remove the correct cache files
   * d/rules: Defang dh_auto_test when built with nocheck
   * Stop using Priority: extra
+  * d/tests/build: Update for GTK+ 4.0
 
  -- Jeremy Bicha <jbicha@debian.org>  Fri, 19 Jan 2018 22:05:35 -0500
 
old mode 100644 (file)
new mode 100755 (executable)
index 1a46e30..5f8caee
@@ -1,6 +1,9 @@
 #!/bin/sh
 # autopkgtest check: Build and run a program against GTK, to verify that the
 # headers and pkg-config file are installed correctly
+# Based on examples/hello-world.c:
+# (C) 1997-2015 GTK+ contributors (see debian/copyright)
+# and on an older autopkgtest:
 # (C) 2012 Canonical Ltd.
 # Author: Martin Pitt <martin.pitt@ubuntu.com>
 
@@ -16,27 +19,41 @@ cat <<EOF > gtktest.c
 static gboolean
 do_quit (gpointer user_data)
 {
-    gtk_main_quit ();
+    gtk_widget_destroy (user_data);
+    g_object_unref (user_data);
+    return G_SOURCE_REMOVE;
+}
+
+static void
+activate (GtkApplication *app,
+          gpointer        user_data)
+{
+    GtkWidget *window;
+
+    window = gtk_application_window_new (app);
+    gtk_window_set_title (GTK_WINDOW (window), "Window");
+    gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
+
+    gtk_widget_show (window);
+    g_timeout_add_seconds (1, do_quit, g_object_ref_sink (window));
 }
 
 int main(int argc, char **argv)
 {
-    GtkWidget *dialog;
-
-    gtk_init (&argc, &argv);
-    dialog = gtk_dialog_new_with_buttons ("Test dialog", NULL,
-                                          GTK_DIALOG_MODAL, 
-                                          "OK", GTK_RESPONSE_ACCEPT, 
-                                          NULL);
-    gtk_widget_show_all (dialog);
-    g_timeout_add_seconds (1, do_quit, NULL);
-    gtk_main();
-    return 0;
+    GtkApplication *app;
+    int status;
+
+    app = gtk_application_new ("org.debian.gtk_4_0.example", G_APPLICATION_NON_UNIQUE);
+    g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+    status = g_application_run (G_APPLICATION (app), argc, argv);
+    g_object_unref (app);
+    return status;
 }
 EOF
 
 gcc -o gtktest gtktest.c `pkg-config --cflags --libs gtk+-4.0`
 echo "build: OK"
 [ -x gtktest ]
-xvfb-run ./gtktest
+#xvfb-run ./gtktest
+./gtktest
 echo "run: OK"